﻿namespace Example.Structural
{
    using Example.Structural.Flyweight;

    using Xunit;

    /// <summary>
    /// Use sharing to support large numbers of fine-grained objects efficiently.
    /// </summary>
    public sealed class FlyweightFacts
    {
        [Fact]
        public void spreadsheet_cell_sharing()
        {
            var spreadsheet = new Spreadsheet();

            var expected = spreadsheet["a", 1];
            var actual = spreadsheet["a", 1];

            Assert.Same(expected, actual);
        }

        [Fact]
        public void spreadsheet_value()
        {
            const string expected = "test";

            var spreadsheet = new Spreadsheet();
            spreadsheet["a", 1].Value = expected;

            var actual = spreadsheet["a", 1].Value;

            Assert.Equal(expected, actual);
        }
    }
}